<section class="content-header">
  <ol class="breadcrumb">
    <li><a ui-sref="dashboard"><i class="fa fa-dashboard"></i>我的面板</a></li>
    <li><a ui-sref="account">记账列表</a></li>
    <li class="active">详情</li>
  </ol>
</section>
<section class="content">
  <form class="form-horizontal view-form" id="account_form">
    <div class="detail-view-header-wrapper">
      <div class="box-footer detail-view-header" ui-scrollpoint ui-scrollpoint-enabled="true" ui-scrollpoint-class="fixed">
        <button type="button" class="btn btn-info" ui-sref="account_edit({id: id})" ng-if="data.status == 0 || data.review_status == 0" ui-sref-opts="{reload:true}">修改</button>
        <!-- <button type="button" class="btn btn-primary" ng-click="submitAudit()" ng-if="data.status == 0 || data.review_status == 0">提交审核</button> -->
        <!-- <button type="button" class="btn btn-success" ng-click="passAuditF()" ng-if="data.status==1 && opers.indexOf(3) > -1">财务审核通过</button> -->
        <!-- <button type="button" class="btn btn-danger" ng-click="refuseAudit()" ng-if="data.status==1 && opers.indexOf(3) > -1">财务审核驳回</button> -->
        <!-- <button type="button" class="btn btn-success" ng-click="passAudit()" ng-if="data.status > 1 && data.status < 3 && opers.indexOf(4) > -1">提交审核通过</button> -->
        <!-- <button type="button" class="btn btn-danger" ng-click="refuseAudit()" ng-if="data.status > 1 && data.status < 3 && opers.indexOf(4) > -1">提交审核驳回</button> -->
        <button type="button" class="btn btn-info" ui-sref="account_timeline({id: data.id, name: 'accounting', code: data.code, source: 'view'})"><span class="fa fa-clock-o"></span>日志</button>
        <!-- <a  ng-if="data.is_annual != 1" href="/print.html?m=account&id={{id}}" class="btn btn-info" target="_blank">打印</a> -->
        <!-- <span>状态: </span>
        <span class="tooltip-author" ng-if="data.status != 4" ng-bind="getOrderStatus() + ' | ' + getReviewStatus()" ng-attr-title="{{getTitle(data)}}" style="cursor: default;"></span>
        <span ng-if="data.status == 4" ng-bind="'已完成 | ' + format(data.date_finish, 'YYYY-MM-DD')"></span> -->
      </div>
    </div>

    <div class="box box-danger">
      <div class="box-header with-border">
        <h3 class="box-title">客户基本信息</h3>
        <div class="box-tools">
          <div class="box-tools pull-right">
            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
            </button>
          </div>
        </div>
      </div>
      <div class="box-body">
        <div class="form-group">
          <label class="col-sm-2 control-label">客户名称</label>
          <div class="col-sm-8">
            <span class="form-span" ng-bind="data.customer_name"></span>
          </div>
        </div>
        <div class="form-group" ng-if="data.industry.length > 0">
          <label class="col-sm-2 control-label">行业类别</label>
          <div class="col-sm-8">
            <span class="form-span" ng-bind="data.industry"></span>
          </div>
        </div>
        <div class="form-group mb-0">
          <label class="col-sm-2 control-label">详细地址:</label>
          <div class="col-sm-8">
            <span class="form-span" ng-bind="data.province + data.city + data.county + data.customer_address + ''"></span>
          </div>
        </div>
      </div>
    </div>
    <div class="box box-danger">
      <div class="box-header with-border">
        <h3 class="box-title">公司信息</h3>
        <div class="box-tools">
          <div class="box-tools pull-right">
            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
            </button>
          </div>
        </div>
      </div>
      <div class="box-body">
        <div class="form-group">
          <label class="col-sm-2 control-label">档案号</label>
          <div class="col-sm-8">
            <span class="form-span" ng-bind="data.code"></span>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">订单来源</label>
          <div class="col-sm-8">
            <span class="form-span" ng-bind="data.source_type=='0'?'国内注册':'转秘书'"></span>
          </div>
        </div>
        <div class="form-group" ng-if="data.source_code.length > 0">
          <label class="col-sm-2 control-label">来源单据</label>
          <div class="col-sm-8">
            <span class="form-span" ng-bind="data.source_code"></span>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">公司名称</label>
          <div class="col-sm-8">
            <span class="form-span" ng-bind="data.name"></span>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">地址</label>
          <div class="col-sm-8">
            <span class="form-span" ng-bind="data.address"></span>
          </div>
        </div>

        <div class="form-group">
          <label class="col-sm-2 control-label">下期收款</label>
          <div class="col-sm-8">
            <span class="form-span" ng-bind="format(data.pay_notify, 'YYYY-MM-DD')"></span>
          </div>
        </div>

        <!-- <div class="form-group">
          <label class="col-sm-2 control-label">成交金额</label>
          <div class="col-sm-8">
            <span class="form-span" ng-bind="data.amount_transaction"></span>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">是否含税</label>
          <div class="col-sm-8">
            <span class="form-span" ng-bind="data.tax==0?'否':'是'"></span>
          </div>
        </div> -->

      </div>
    </div>

    <!-- <div class="box box-danger">
      <div class="box-header with-border">
        <h3 class="box-title">开票信息</h3>
        <div class="box-tools">
          <div class="box-tools pull-right">
            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
            </button>
          </div>
        </div>
      </div>
      <div class="box-body" ng-if="data.tax == 1">
        <div class="form-group">
          <label class="col-sm-2 control-label">名称</label>
          <div class="col-sm-8">
            <span class="form-span" ng-bind="data.invoice_name"></span>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">纳税人识别号</label>
          <div class="col-sm-8">
            <span class="form-span" ng-bind="data.invoice_tax"></span>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">地址</label>
          <div class="col-sm-8">
            <span class="form-span" ng-bind="data.invoice_address"></span>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">电话</label>
          <div class="col-sm-8">
            <span class="form-span" ng-bind="data.invoice_tel"></span>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">开户行</label>
          <div class="col-sm-8">
            <span class="form-span" ng-bind="data.invoice_bank"></span>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">开户行账号</label>
          <div class="col-sm-8">
            <span class="form-span" ng-bind="data.invoice_account"></span>
          </div>
        </div>
      </div>
    </div> -->

    <div class="box box-danger" style="padding-bottom: 100px;margin-bottom: 100px;">
      <div class="box-header with-border">
        <h3 class="box-title">账期</h3>
        <div class="box-tools">
          <div class="box-tools pull-right">
            <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
            </button>
          </div>
        </div>
      </div>
      <div class="box-body" style="padding:0px;">
        <div class="box audit-box collapsed-box" ng-repeat="item in items">
          <div class="box-header">
            <h3 class="box-title" ng-bind="'账期' + ($index+1)"></h3>
            <div class="box-tools box-expand">
              <button type="button" class="btn btn-box-tool" data-widget="collapse" ng-click="expandSub(item, $event)"><i class="fa fa-plus"></i>
              </button>
            </div>

            <div class="box-tools pull-right">
              <button type="button" class="btn btn-box-tool" ui-sref=".editsub({sub_id: item.id})"  ui-sref-opts="{location:false}" ng-if="item.status == 0 || item.review_status == 0">修改</button>
              <button type="button" class="btn btn-box-tool" ng-click="submitSubAudit(item.id, $index)" ng-if="item.status == 0 || item.review_status == 0">提交审核</button>
              <button type="button" class="btn btn-box-tool" ng-click="passSubAuditF(item.id, $index)" ng-if="item.status==1 && opers.indexOf(3) > -1">财务审核通过</button>
              <button type="button" class="btn btn-box-tool" ng-click="refuseSubAudit(item.id, $index)" ng-if="item.status==1 && opers.indexOf(3) > -1">财务审核驳回</button>
              <button type="button" class="btn btn-box-tool" ng-click="passSubAudit(item.id, $index)" ng-if="item.status > 1 && item.status < 3 && opers.indexOf(4) > -1">提交审核通过</button>
              <button type="button" class="btn btn-box-tool" ng-click="refuseSubAudit(item.id, $index)" ng-if="item.status > 1 && item.status < 3 && opers.indexOf(4) > -1">提交审核驳回</button>
              <button type="button" class="btn btn-box-tool" ui-sref=".progress_add({item_id: item.id})" ui-sref-opts="{location:false}" ng-if="item.status >= 3">进度反馈</button>
              <button type="button" class="btn btn-box-tool" ui-sref="audit_timeline({masterid: item.master_id, id: item.id, name: 'accounting_item', code: data.code, source: 'view'})"><span class="fa fa-clock-o"></span>日志</button>
              <a href="/print.html?m=accounting&id={{item.id}}" class="btn btn-box-tool" target="_blank">打印</a>
              <span>状态: </span>
              <span class="tooltip-author" ng-if="item.status != 4" ng-bind="getSubOrderStatus(item) + ' | ' + getSubReviewStatus(item)" ng-attr-title="{{getTitle(item)}}" style="cursor: default;"></span>
              <span ng-if="item.status == 4" ng-bind="'已完成 | ' + format(item.date_finish, 'YYYY-MM-DD')"></span>
            </div>
          </div>
          <div class="box-body">
            <div class="nav-tabs-custom" style="box-shadow:none;">
              <ul class="nav nav-tabs">
                <li ng-class="{'active': item.activeTab == 0}"><a data-toggle="tab"  ng-click="onTab(item, 0)">基本信息</a></li>
                <li ng-class="{'active': item.activeTab == 2}"><a data-toggle="tab" ng-click="onTab(item, 2)">人员信息</a></li>
                <li ng-class="{'active': item.activeTab == 1}"><a data-toggle="tab" ng-click="onTab(item, 1)" ng-if="item.tax == 1">开票信息</a></li>
              </ul>
              <div class="tab-content">
                <div class="tab-pane" ng-class="{'active': item.activeTab == 0}" style="min-height: 224px;">
                  <div class="form-group">
                    <label class="col-sm-1 control-label">账期</label>
                    <div class="col-sm-8">
                      <span class="form-span" ng-bind="format(item.date_start, 'YYYY-MM') + ' 至 ' + format(item.date_end, 'YYYY-MM')"></span>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-1 control-label">月数</label>
                    <div class="col-sm-8">
                      <span class="form-span" ng-bind="getMonths(item)"></span>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-1 control-label">成交日期</label>
                    <div class="col-sm-8">
                      <span class="form-span" ng-bind="format(item.date_transaction, 'YYYY-MM-DD')"></span>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-1 control-label">成交金额</label>
                    <div class="col-sm-8">
                      <span class="form-span" ng-bind="item.amount_transaction"></span>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-1 control-label">付款方式</label>
                    <div class="col-sm-8">
                      <span class="form-span" ng-bind="getPayMode(item.pay_mode)"></span>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-1 control-label">是否含税</label>
                    <div class="col-sm-8">
                      <span class="form-span" ng-bind="item.tax==0?'否':'是'"></span>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-1 control-label">其他事项</label>
                    <div class="col-sm-8">
                      <textarea class="form-control" rows="3" name="item.memo" ng-model="item.memo" readonly style="background:#fff;border:none;"></textarea>
                    </div>
                  </div>
                </div>
                <div class="tab-pane" ng-class="{'active': item.activeTab == 2}" style="min-height: 224px;">
                  <div class="form-group">
                    <label class="col-sm-1 control-label">客户归属</label>
                    <div class="col-sm-8">
                      <span class="form-span" ng-bind="item.salesman"></span>
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="col-sm-1 control-label">订单归属</label>
                    <div class="col-sm-8">
                      <span class="form-span" ng-bind="item.creator"></span>
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="col-sm-1 control-label">渠道商</label>
                    <div class="col-sm-8">
                      <span class="form-span" ng-bind="item.trader_name"></span>
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="col-sm-1 control-label">供应商</label>
                    <div class="col-sm-8">
                      <span class="form-span" ng-bind="item.supplier_name"></span>
                    </div>
                  </div>

                  <div class="form-group">
                    <label class="col-sm-1 control-label">助理</label>
                    <div class="col-sm-8">
                      <span class="form-span" ng-bind="item.assistant_name"></span>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-1 control-label">经理</label>
                    <div class="col-sm-8">
                      <span class="form-span" ng-bind="item.manager_name"></span>
                    </div>
                  </div>
                </div>
                <div class="tab-pane" ng-class="{'active': item.activeTab == 1}" style="min-height: 224px;">
                  <div class="form-group">
                    <label class="col-sm-1 control-label">名称</label>
                    <div class="col-sm-8">
                      <span class="form-span" ng-bind="item.invoice_name"></span>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-1 control-label">纳税人识别号</label>
                    <div class="col-sm-8">
                      <span class="form-span" ng-bind="item.invoice_tax"></span>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-1 control-label">地址</label>
                    <div class="col-sm-8">
                      <span class="form-span" ng-bind="item.invoice_address"></span>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-1 control-label">电话</label>
                    <div class="col-sm-8">
                      <span class="form-span" ng-bind="item.invoice_tel"></span>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-1 control-label">开户行</label>
                    <div class="col-sm-8">
                      <span class="form-span" ng-bind="item.invoice_bank"></span>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="col-sm-1 control-label">开户行账号</label>
                    <div class="col-sm-8">
                      <span class="form-span" ng-bind="item.invoice_account"></span>
                    </div>
                  </div>
                </div>
              </div>
            </div>

            <fieldset>
              <legend>进度反馈:</legend>
              <table class="table table-hover">
                <tbody>
                  <tr>
                    <th style="width: 10px">#</th>
                    <th>完成日期</th>
                    <th>账期</th>
                    <th>进度</th>
                    <th>附件</th>
                    <th class="opt-col">操作</th>
                  </tr>
                  <tr ng-repeat="progress in item.progressList">
                    <td ng-bind="($index+1)+'.'"></td>
                    <td ng-bind="format(progress.date_start, 'YYYY-MM-DD')"></td>
                    <td ng-bind="progress.period"></td>
                    <td ng-bind="progress.progress"></td>
                    <td>
                      <a href="{{progress.attachment}}" target="_blank" ng-if="progress.attachment.length">
                        <img ng-src="{{progress.attachment}}" width="22" height="22">
                      </a>
                    </td>
                    <td class="opt-col">
                      <a class="fa fa-pencil orange" ui-sref=".progress_edit({tid: {{progress.id}}})" ui-sref-opts="{location:false}" title="修改"></a>
                      <a href="javascript:;" class="fa fa-trash-o red" ng-click="deleteProgress(progress)" title="删除"></a>
                    </td>
                  </tr>
                </tbody>
              </table>
              <div style="margin-left:10px;">
                <!-- <button type="button" class="btn btn-info" ui-sref=".progress_add({item_id: item.id})" ui-sref-opts="{location:false}">进度反馈</button> -->
              </div>
            </fieldset>

            <fieldset>
              <legend>收款记录:</legend>
              <table class="table table-hover">
                <tbody>
                  <tr>
                    <th style="width: 10px">#</th>
                    <th>付款人</th>
                    <th>收款银行</th>
                    <th>收款账号</th>
                    <th>收款金额</th>
                    <th>币别</th>
                    <th>汇率</th>
                    <th>收款方式</th>
                    <th>收款时间</th>
                    <th>附件</th>
                    <th>备注</th>
                    <th class="opt-col">操作</th>
                  </tr>
                  <tr ng-repeat="income in item.incomes.items">
                    <td ng-bind="($index+1)+'.'"></td>
                    <td ng-bind="income.payer"></td>
                    <td ng-bind="income.bank"></td>
                    <td ng-bind="income.account"></td>
                    <td ng-bind="income.amount"></td>
                    <td ng-bind="item.currency"></td>
                    <td ng-bind="item.rate"></td>
                    <td ng-bind="income.pay_way"></td>
                    <td ng-bind="format(income.date_pay, 'YYYY-MM-DD')"></td>
                    <td>
                      <a href="{{income.attachment_url}}" target="_blank" ng-if="income.attachment_url.length">
                        <img ng-src="{{income.attachment_url}}" width="22" height="22">
                      </a>
                    </td>
                    <td ng-bind="income.description"></td>
                    <td class="opt-col">
                      <a ng-if="item.status == 0" class="fa fa-pencil orange" ui-sref=".income_edit({source_name: 'accounting_item', tid: {{income.id}}})" ui-sref-opts="{location:false}" title="修改"></a>
                      <a ng-if="item.status == 0" href="javascript:;" class="fa fa-trash-o red" ng-click="deleteIncome(income)" title="删除"></a>
                      <a href="/print.html?m=account_line&id={{income.id}}" target="_blank">打印</a>
                    </td>
                  </tr>
                  <tr>
                    <td></td>
                    <td class="summary" colspan="11">
                      <div>
                        <span>本币: </span>
                        <span class="num">人民币</span>
                      </div>
                      <div>
                        <span>应收款: </span>
                        <span class="num receivable" ng-bind="item.incomes.amount"></span>
                      </div>
                      <div>
                        <span>已收款: </span>
                        <span class="num received" ng-bind="item.incomes.total"></span>
                      </div>
                      <div>
                        <span>未收款: </span>
                        <span class="num balance" ng-bind="item.incomes.balance"></span>
                      </div>
                    </td>
                  </tr>
                </tbody>
              </table>
              <div class="box-footer clearfix">
                <button type="button" class="btn btn-info" ng-disabled="$index < (items.length - 1)" ui-sref=".income_add({source_name: 'accounting_item', customer_id: data.customer_id, subId: item.id})" ui-sref-opts="{location:false}">新增</button>
                <button type="button" class="btn btn-info" ng-click="printReceipt('new')">新增收据</button>
                <button type="button" class="btn btn-info" ng-click="printReceipt('print')">打印收据</button>
              </div>
            </fieldset>
          </div>
        </div>
      </div>

      <div class="box-footer clearfix">
        <button type="button" class="btn btn-info" ng-disabled="getDisabled()" ui-sref=".addsub()" ui-sref-opts="{location:false}">新增账期</button>
      </div>
    </div>
  </form>
</section>
<div ui-view="modal"></div>
<div ui-view="progress"></div>
<div ui-view="print"></div>
<div ui-view="attachment"></div>
<div ui-view="sub"></div>
